<%@page import="com.sinodata.bsm.center.cache.TopuConfCache"%>
<%@page import="com.sinodata.bsm.center.service.config.APPService"%>
<%@page import="com.sinodata.bsm.center.service.relation.ResRelationService"%>
<%@page import="com.sinodata.bsm.center.cache.MotiResRelCache"%>
<%@page import="com.sinodata.bsm.center.cache.ResGroupCache"%>
<%@page import="com.sinodata.bsm.center.bean.ResTypeBean"%>
<%@page import="com.sinodata.bsm.center.bean.ResBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.sinodata.bsm.center.util.spring.SpringContextHolder"%>
<%@page import="com.sinodata.bsm.center.service.resource.ResService"%>
<%@ page import="com.sinodata.bsm.common.vo.*" %>
<%@ page import="com.sinodata.bsm.common.utils.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
	ResService service = SpringContextHolder.getBean(ResService.class);
	ResGroupCache resGroupCache = SpringContextHolder.getBean(ResGroupCache.class);
	MotiResRelCache motiResRelCache = SpringContextHolder.getBean(MotiResRelCache.class);
	ResRelationService resRelationService = SpringContextHolder.getBean(ResRelationService.class);
	
	APPService appService = SpringContextHolder.getBean(APPService.class);
	TopuConfCache topuConfCache = SpringContextHolder.getBean(TopuConfCache.class);
	
	String resid = request.getParameter("resid");
	List<Long> startResIds = resRelationService.getResByEndId(Long.valueOf(resid),203L);
	
	List<ResGroup> resGroups = resGroupCache.findByResId(Long.valueOf(resid));
	ResGroup jkglGroup = null;
	if(resGroups!=null){
		for(ResGroup group:resGroups){
		    if(group.getContainType()!=null&&group.getContainType()==100L){
		        jkglGroup = group;
		        break;
		    }
		}
	}
	List<MotiResRel> motiResRels = new ArrayList<MotiResRel>();
	if(jkglGroup!=null){
	    motiResRels = motiResRelCache.findByResGroupId(jkglGroup.getId());
	}
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<%@ include file="../include/taglib.jsp"%>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/table.jsp"%>
<title>中科金财IT综合监控系统</title>
<link href="/bsm/style/default/bsm/tab.css" rel="stylesheet" type="text/css">
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/style/default/bsm/appviewdetail.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jcarousellite_1.0.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>
<script type="text/javascript">
	function add(){
		var url ="iframe:appview/app!add.action?resId=<%=resid%>";
		var opt = { title: "应用拓扑图配置",width:550,height:400,buttons: {}};
		getTopWin(window).openjBox(url,opt,'add-topo',window);
	}
	function addRel(){
		var url ="iframe:appview/app!initUpdate.action?id=<%=resid%>";
		var opt = { title: "系统关联配置",width:600,height:350,buttons: {}};
		getTopWin(window).openjBox(url,opt,'add-topo',window);
	}
	function del(id){
	
		 $.ajax({
			   type: "POST", 
			   url: "${pageContext.request.contextPath}/appview/app!delete.action", //请求的action
			   data:{id:id}, //传的参数
			   dataType: 'json',
			   success: function(data){ //结果
				   window.location.reload();
			   }
		});
	}
	$(document).ready(function() {
	initTop();

});
	
</script>
<style type="text/css">
.col-l{
float:left;
width:80%;
}
.col-r{
	float:right;
	width:19.5%;
	background:#ecf6fc;
	border-right:1px solid #cfe9fe; border-left:1px solid #cfe9fe;border-bottom:1px solid #cfe9fe; position:relative;
}
.yygltp{
background:#fff;
}
.jkgl{
 margin-top:8px;
 }
 .bg_no{
 background-image:none;
 }
 .bg_no a p{
  width:auto;
  }
  .tuopu a{
  height:30px;
  text-align:left;
  line-height:30px;
  text-indent:8px;
  color:#005aaa;
  text-decoration:underline;
  }
  h2 span{
	font-family: Arial;
	font-family: 微软雅黑;
	font-weight: 600;
	font-size: 14px;
	color: #091782;
	float:left;
}
div.tuopu h2 a{
  float:right;
  width:auto;
  margin:3px 6px 0px 0px;  
}
  .tuopu a:hover{
  color:#f00;
  }
   .left2{margin-right:208px;
       }
   .right2{width:200px; position:absolute; top:261px; right:10px; z-index:555;}
   .left2-p{ padding:20px; background:#444;}
   .right2-p{padding:20px; background:666;}
   div#topo_div span{
   width:100%;
   height:30px;
   display:block;
   position:relative;
   }
   div#topo_div span a.text_tu{
    float:left;
   }
   div#topo_div span a.shanchu{
    position:absolute;
    top:6px;
    right:10px;
    z-index:99;
   	cursor:pointer;
   }
</style>

</head>
<body>
  <div class="max">
   		<jsp:include page="viewdetailtop.jsp">
        	<jsp:param name="resid" value="<%=resid %>" ></jsp:param>
        	<jsp:param name="pageno" value="3" ></jsp:param>
         </jsp:include>
  		<div class="container">
 			<div class="yygl-max">

		  		<!--左边-->
				<div class="left2">
           			<!--系统关联-->
        			<div class="xtgl">
		  				<b class="b1"></b>
		  				<b class="b2"></b>
		  				<b class="b3"></b>
		  				<b class="b4"></b>  
		  				<div class="content"> 
		   					<h2>系统关联<a href="javascript:addRel();" style="float:right;margin:3px 6px 0px 0px;cursor:pointer;"><img src="${pageContext.request.contextPath}/style/default/bsm/appview/add.png"/></a></h2>
							<div class="colD">		
								<%
								if(startResIds!=null&&startResIds.size()>0){
									for(Long resId:startResIds){
									    Res res = ResBean.get(resId).res();
								%>
								<div class="por_div">
					 				<img src="${pageContext.request.contextPath}/style/default/bsm/appview/Core.png" />
									<a href="viewdetail1.jsp?resid=<%=res.getId() %>" target="_blank" ><p><%=res.getName()%></p></a>
									<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>	
				 				</div>
								<%}}else{ %>
									<div class="por_div_nothing"></div>
								<%} %>
 							</div>
	      				</div>
					</div>
		 			<!--@end 系统关联-->
		   			<!--接口关联-->
        			<div class="jkgl">
		  				<b class="b1"></b>
		  				<b class="b2"></b>
		  				<b class="b3"></b>
		  				<b class="b4"></b>  
		  				<div class="content"> 
		    				<h2>接口关联</h2>
		    				<div class="colD">
		    				<%
		    				if(motiResRels!=null&&motiResRels.size()>0){
		    					for(MotiResRel motiResRel:motiResRels){
	    							Res res = ResBean.get(motiResRel.getResId()).res();
	    					%>
				 				<div class="por_div">
					 				<img src="${pageContext.request.contextPath}/style/default/bsm/appview/s01.png" />
									<a href="${pageContext.request.contextPath}/resource/res-query!view.action?id=<%=res.getId() %>&pId=0&viewId=1&ntype=2" target="_blank" ><p><%=res.getName() %></p></a>
									<a href="#" target="_blank"  class="Alarm"><img src="/bsm/style/default/tree/node/res<%=res.getHealthStatus() %>.png"/></a>	
				 				</div>
	    					<% }}else{%>
	    						<div class="por_div_nothing"></div>
	    					<%} %>
				 			<br class="clear" />
 						</div>
	      			</div>
		 		</div>
		 		<!--@end 接口关联-->
	  	 	</div>
			<div class="right2">
				<div class="yygltp">
		  			<b class="b1"></b>
		 			<b class="b2"></b>
		  			<b class="b3"></b>
		  			<b class="b4"></b>  
		  			<div class="content tuopu"  style="height:296px;"> 
		   				<h2><span>应用关联拓扑图</span><a href="javascript:add();"><img src="${pageContext.request.contextPath}/style/default/bsm/appview/add.png"/></a></h2>
		   				<br />
		   				<div id="topo_div" name="topo_div" >		   				 
		   					<% List<AppresTopoRel> appresTopoRelList = appService.getAllAppresTopoRel();
		   						 List<AppresTopoRel> selectedList = new ArrayList<AppresTopoRel>();
		   						  if(appresTopoRelList!=null&&appresTopoRelList.size()>0){
		   						      for(AppresTopoRel appresTopoRel:appresTopoRelList){
		   						         if(appresTopoRel.getResId()==Long.parseLong(resid) && appresTopoRel.getTab()==3){
		   						     
		   						             selectedList.add(appresTopoRel);
		 		   				         }
		   						      }
		   						  }
		   						  AppresTopoRel[] arr = selectedList.toArray(new AppresTopoRel[selectedList.size()]);
		   						  String ids = "";
		   						  for(int i=0; i<arr.length; i++){
		   						      TopuConf topuConf = topuConfCache.get(arr[i].getTopuConfId());
		   						      ids=topuConf.getId().toString();
		   						      for(int j=0; j<arr.length; j++){
		   						          if(i!=j){
		   						              ids+=","+arr[j].getTopuConfId().toString();
		   						          }
		   						      }
		   							out.println("<span><a class='text_tu' href='/bsm/resources/flash/BSTopoShowMain.html?topoId="+ids+"' target='_blank'>"+topuConf.getName()+"</a> &nbsp;<a class='shanchu'><img src='../../style/default/bsm/images/delete.gif' title='删除' onclick='del("+arr[i].getId()+")'></a></span>");
		   						
		   						  }
		   					%>
		   				</div>
	       			</div>
		  		</div>
		 	</div>
   		</div>
 	 </div>
	</div>
</body>
</html>

